Computer programs are normally compiled into binary code for a particular computer processor architecture. This causes a problem when the computer processor evolves to implement more advanced instruction sets, more powerful functional units, or different data formats. Each time a new generation of processors is introduced, computer hardware and software venders have to spend significant engineering resources as well as monetary resources to help the old computer programs to run on the new computer processors.
In modern computers, compiled binary code is typically decoded into microcode by a decoder at the front end of a processor. One existing approach to enable old software to run on new processors is dynamic binary translation that translates the binary code from one instruction set to another instruction set. If the compiled binary code contains a hot spot, which is a frequently executed portion of the program, binary translation can be performed on a code region containing the hot spot instead of on the entire code. The result of such partial binary translation is processor-specific and optimized code.
To perform partial binary translation on hot spots, an effective hot spot detection mechanism needs to be in place first. Conventional hot spot detection mechanisms collect and analyze the runtime statistics of binary code to thereby determine the existence of a hot spot. However, conventional hot spot detection mechanisms can use a large amount of memory for storing the collected statistics and can incur significant hardware cost for tracking the runtime behavior of the binary code.
After a hot spot is detected, translator software is invoked to produce an optimized version of the hot spot code. The optimized code is then installed in memory and the optimized version is executed instead of the original native code. The process of finding and optimizing hot spots takes a considerable amount of processing time and hardware resources, which could otherwise be spent executing native code. However, due to the hardware and software limitations, current systems identify and translate the same hot spots, as well as store and install the same optimized code for each virtual address and context in which the hot spots were detected. Thus, the hot spots contained in the same code are redetected and reinstalled every time a new context is created, even if the whole process had been performed previously for the same code. Therefore, system resources are utilized inefficiently and system performance is degraded.